# Maintainer: J. Peter Mugaas <jpmugaas@suddenlink.net>

_realname=pretend
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python2-${_realname}"  "${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=1.0.9
pkgrel=3
pkgdesc="A library for stubbing in Python (mingw-w64)"
arch=('any')
license=('BSD')
url="https://github.com/alex/pretend"
makedepends=("${MINGW_PACKAGE_PREFIX}-python3-setuptools" "${MINGW_PACKAGE_PREFIX}-python2-setuptools")
source=("https://pypi.python.org/packages/source/p/pretend/pretend-$pkgver.tar.gz")
sha256sums=('c90eb810cde8ebb06dafcb8796f9a95228ce796531bc806e794c2f4649aa1b10')

prepare() {  
  cd "$srcdir"/  
  for pver in {2,3}; do 
    rm -rf python${pver}-build-${CARCH} | true
    cp -r "${_realname}-${pkgver}" "python${pver}-build-${CARCH}"
  done
}  

# Note that build() is sometimes skipped because it's done in 
# the packages setup.py install for simplicity if you can do so.
# but sometimes, you want to do a check before install which would
# also trigger the build.  
build() {  
  for pver in {2,3}; do  
    msg "Python ${pver} build for ${CARCH}"  
    cd "${srcdir}/python${pver}-build-${CARCH}"
    ${MINGW_PREFIX}/bin/python${pver} setup.py build
  done  
}

package_python3-pretend() {
  depends=("${MINGW_PACKAGE_PREFIX}-python3")

  cd "${srcdir}/python3-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python3 setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build
  install -D -m644 LICENSE.rst "${pkgdir}${MINGW_PREFIX}/share/licenses/python3-${_realname}/LICENSE.rst"
}

package_python2-pretend() {
  depends=("${MINGW_PACKAGE_PREFIX}-python2")

  cd "${srcdir}/python2-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python2 setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build

  install -D -m644 LICENSE.rst "${pkgdir}${MINGW_PREFIX}/share/licenses/python2-${_realname}/LICENSE.rst"
}


package_mingw-w64-i686-python2-pretend() {
  package_python2-pretend
}

package_mingw-w64-i686-python3-pretend() {
  package_python3-pretend
}

package_mingw-w64-x86_64-python2-pretend() {
  package_python2-pretend
}

package_mingw-w64-x86_64-python3-pretend() {
  package_python3-pretend
}
